// Definitions of the basic types
//

#ifndef __TYPES_H__
#define __TYPES_H__

/////////////////////////////////////////////////////////////////////////////
// Use these types to get a guaranteed size in different platforms

typedef signed char			Int8;		// 8 bits signed integer
typedef unsigned char		UInt8;		// 8 bits unsigned integer
                               
typedef signed short		Int16;      // 16 bits signed integer
typedef unsigned short		UInt16;     // 16 bits unsigned integer
                               
typedef signed long			Int32;      // 32 bits signed integer
typedef unsigned long		UInt32;     // 32 bits unsigned integer
                               
#ifdef _MSC_VER	// if on M$VC++
typedef signed __int64		Int64;		// 64 bits signed integer
typedef unsigned __int64	UInt64;     // 64 bits unsigned integer
#else
typedef signed long long	Int64; 
typedef unsigned long long  UInt64;         
#endif

typedef float				Real32;     // 32 bits floating point
typedef double				Real64;		// 64 bits floating point

/*
    The ranges of above types
*/
#ifndef INT8_MIN

#define  INT8_MIN       -128            // 0x00
#define  INT8_MAX       127             // 0x7F

#define  UINT8_MIN      0               // 0x00
#define  UINT8_MAX      255             // 0xFF

#define  INT16_MIN      -32768          // 0x8000   
#define  INT16_MAX      32767           // 0x7FFF

#define  UINT16_MIN     0               // 0x0000
#define  UINT16_MAX     65535           // 0xFFFF

#define  INT32_MIN      -2147483648L    // 0x80000000
#define  INT32_MAX      2147483647L     // 0x7FFFFFFF

#define  UINT32_MIN     0
#define  UINT32_MAX     4294967295UL    // 0xFFFFFFFF

#endif	// INT8_MIN

#define  REAL32_MIN     1.175494351e-38F    // minimum positive value
#define  REAL32_MAX     3.402823466e+38F    // maximum positive value

#define  REAL64_MIN     2.2250738585072014e-308	
#define  REAL64_MAX     1.7976931348623158e+308


/////////////////////////////////////////////////////////////////////////////
// Machine dependent operations

#ifdef WIN_PC

#define _UINT16(ptr)		(*(UInt16*)(ptr))
#define _UINT32(ptr)		(*(UInt32*)(ptr))

#else

#define _UINT16(ptr)		((*(UInt8*)((ptr)+1) << 8) | *(UInt8*)(ptr))
#define _UINT32(ptr)		((*(UInt16*)((ptr)+2) << 16) | *(UInt16*)(ptr))

#endif


/////////////////////////////////////////////////////////////////////////////
// Definitions of custom types

#ifndef _MAX_PATH
#define _MAX_PATH	256
#endif

typedef int				BOOL;
typedef unsigned char	BYTE;

// The value of boolean
#ifndef TRUE
    #define  TRUE       ((BOOL)1)
    #define  FALSE      ((BOOL)0)
#endif

typedef struct _TRect
{
    long    left;
    long    top;
    long    right;
    long    bottom;
} TRect;

typedef struct _TPoint
{
    long	x;
    long	y;
} TPoint;

typedef struct _TSize
{
    long    cx;
    long    cy;
} TSize;

typedef struct _TSPoint
{
    short   x;
    short   y;
} TSPoint;

#endif  // __TYPES_H__
